package com.hyy.nio.c2;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.nio.charset.Charset;

public class WriteClient {
    public static void main(String[] args) throws IOException {
        SocketChannel socketChannel = SocketChannel.open();
        socketChannel.connect(new InetSocketAddress("localhost",8080));
        int count = 0;
        while(true){
            ByteBuffer byteBuffer = ByteBuffer.allocate(1024*1024);
            int read = socketChannel.read(byteBuffer);
            byteBuffer.clear();
            if(read>0){
                count += read;
            }
            System.out.println(count);

        }
    }
}
